Skip to content

replace pkg_resources with importlib.resources#136

Closed
will-moore wants to merge 3 commits intoome:masterfrom
will-moore:pkg_resources_replaced
Closed

replace pkg_resources with importlib.resources#136
will-moore wants to merge 3 commits intoome:masterfrom
will-moore:pkg_resources_replaced

Conversation

@will-moore
Copy link
Member

Try to fix https://github.com/pwalczysko/idr-gallery/actions/runs/22069104571/job/63768658012
caused by recent release of setuptools without pkg_resources - see pypa/setuptools#5007

Traceback (most recent call last):
  File "/opt/omero/web/venv3/bin/omego", line 5, in <module>
    from omego.main import entry_point
  File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/omego/main.py", line 39, in <module>
    from .version import Version
  File "/opt/omero/web/venv-3.12/lib64/python3.12/site-packages/omego/version.py", line 25, in <module>
    from pkg_resources import resource_string
ModuleNotFoundError: No module named 'pkg_resources'

@pwalczysko
Copy link
Member

The problem is that the testing framework on this repo is outdated too. imho the GHA here is waiting (in vain) for availability of ubuntu20.04 image. I will try to upgrade this.

@will-moore
Copy link
Member Author

Ah, yes I read at https://github.com/orgs/community/discussions/62365#discussioncomment-6909572 that if you've specified runner setup that isn't available, it just waits forever

@pwalczysko
Copy link
Member

./omego/version.py:35:80: E501 line too long (91 > 79 characters)

cc @will-moore ^^

@pwalczysko
Copy link
Member


  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/command/test.py", line 47, in run
    raise RuntimeError("Support for the test command was removed in Setuptools 72")

@pwalczysko
Copy link
Member

pwalczysko commented Feb 17, 2026

@will-moore

I am at the stage where I can run tests on my branch (which is on top of this PR).

Details

Traceback (most recent call last):
  File "/home/runner/work/omego/omego/setup.py", line 105, in <module>
    setup(name='omego',
  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/__init__.py", line 108, in setup
    return distutils.core.setup(**attrs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 184, in setup
    return run_commands(dist)
           ^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
    dist.run_commands()
  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 970, in run_commands
    self.run_command(cmd)
  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/dist.py", line 956, in run_command
    super().run_command(command)
  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/_distutils/dist.py", line 989, in run_command
    cmd_obj.run()
  File "/home/runner/work/omego/omego/.tox/py312/lib/python3.12/site-packages/setuptools/command/test.py", line 223, in run
    self.run_tests()
  File "/home/runner/work/omego/omego/setup.py", line 81, in run_tests
    import pytest
  File "/home/runner/work/omego/omego/.eggs/pytest-4.6.11-py3.12.egg/pytest.py", line 8, in <module>
    from _pytest.assertion import register_assert_rewrite
  File "/home/runner/work/omego/omego/.eggs/pytest-4.6.11-py3.12.egg/_pytest/assertion/__init__.py", line 13, in <module>
    from _pytest.assertion import rewrite
  File "/home/runner/work/omego/omego/.eggs/pytest-4.6.11-py3.12.egg/_pytest/assertion/rewrite.py", line 9, in <module>
    import imp
ModuleNotFoundError: No module named 'imp'
py312: exit 1 (11.88 seconds) /home/runner/work/omego/omego> bash ./ci-build pid=3159

See below.

I think we should be able to fix the 6 failing tests below.


============================= test session starts ==============================
platform linux -- Python 3.10.19, pytest-9.0.2, pluggy-1.6.0 -- /home/runner/work/omego/omego/.tox/py310/bin/python
cachedir: .tox/py310/.pytest_cache
rootdir: /home/runner/work/omego/omego
plugins: typeguard-4.3.0
collecting ... collected 16 items / 3 deselected / 13 selected
test/integration/test_download.py::TestDownloadJenkins::testDownloadNoUnzip FAILED [  7%]
test/integration/test_download.py::TestDownloadJenkins::testDownloadUnzip FAILED [ 15%]
test/integration/test_download.py::TestDownloadJenkins::testDownloadUnzipDir FAILED [ 23%]
test/integration/test_download.py::TestDownloadJenkins::testDownloadSym FAILED [ 30%]
test/integration/test_download.py::TestDownloadJenkins::testDownloadBuildNumber FAILED [ 38%]
test/integration/test_download.py::TestDownloadJenkins::testDownloadList PASSED [ 46%]
test/integration/test_download.py::TestDownloadRelease::testDownloadRelease PASSED [ 53%]
test/integration/test_download.py::TestDownloadRelease::testDownloadNonExistingArtifact PASSED [ 61%]
test/integration/test_download.py::TestDownloadBioFormats::testDownloadJar FAILED [ 69%]
test/integration/test_upgrade.py::TestUpgrade::testUpgradeHelp PASSED    [ 76%]
test/integration/test_upgrade.py::TestUpgrade::testUpgradeDryRun PASSED  [ 84%]
test/integration/test_upgrade.py::TestUpgrade::testUpgradeDryRunVerbose PASSED [ 92%]
test/integration/test_upgrade.py::TestUpgrade::testSkipunzip PASSED      [100%]

@pwalczysko
Copy link
Member

@will-moore After I fixed (or rather commented out) the failing tests, I got

Successfully installed omego-0.7.1.dev0
+ omego version
Traceback (most recent call last):
  File "/home/runner/work/omego/omego/.tox/py310/bin/omego", line 6, in <module>
    sys.exit(entry_point())
  File "/home/runner/work/omego/omego/.tox/py310/lib/python3.10/site-packages/omego/main.py", line 48, in entry_point
    main("omego", items=[
  File "/home/runner/work/omego/omego/.tox/py310/lib/python3.10/site-packages/yaclifw/framework.py", line 188, in main
    ns.func(ns)
  File "/home/runner/work/omego/omego/.tox/py310/lib/python3.10/site-packages/omego/version.py", line 35, in __call__
    data = importlib.resources.files(__name__).joinpath(
  File "/opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/importlib/_common.py", line 22, in files
    return from_package(get_package(package))
  File "/opt/hostedtoolcache/Python/3.10.19/x64/lib/python3.10/importlib/_common.py", line 68, in get_package
    raise TypeError(f'{package!r} is not a package')
TypeError: 'omego.version' is not a package
py310: exit 1 (20.67 seconds) /home/runner/work/omego/omego> bash ./ci-build pid=2794
  py310: FAIL code 1 (27.91=setup[7.24]+cmd[20.67] seconds)
  evaluation failed :( (27.96 seconds)

This seems to be caused by the present PR

Copy link
Member

@pwalczysko pwalczysko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please address last comment

@pwalczysko
Copy link
Member

@will-moore I would suggest closing this as #137 has all 3 commits from here and its tests are running&passing. Would you please review #137 ? Thank you

@will-moore will-moore closed this Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants